package com.ruoyi.web.controller.yada;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain_yada.AustraliaMiddleEastVO;
import com.ruoyi.system.domain_yada.GlobalTypeVO;
import com.ruoyi.system.service_yada.IAustraliaMiddleEastService;
import com.ruoyi.system.service_yada.IGlobalTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.List;

/**
 *全球各类型占比
 */
@RestController
@RequestMapping("/monitor/clobal")
@Api(tags = "全球各类型占比")
public class GlobalTypeController {
    @Resource
    private IGlobalTypeService typeService;

    /**
     * 查询方法
     * @param response 响应头
     * @param request 客户端请求
     * @return 参数类
     */
    @RequestMapping(value = "/selectGlobalType",method = {RequestMethod.POST})
    @ApiOperation(value = "查询方法",httpMethod = "POST")
    public AjaxResult selectGlobalType(HttpServletResponse response, HttpServletRequest request,@RequestBody GlobalTypeVO TypeVO)
    {
        List<GlobalTypeVO> eastVOSList= typeService.selectGlobalType(TypeVO.getTypeName(),TypeVO.getParticularYear());
        return AjaxResult.success(eastVOSList);
    }

    /**
     * 删除方法
     * @param ID id
     * @return 状态码
     */
    @RequestMapping(value = "/DelGlobalType",method = {RequestMethod.DELETE})
    @ApiOperation(value = "删除方法",httpMethod = "DELETE")
    @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
    public AjaxResult DelGlobalType(@Param("ID") String ID)
    {
        int NUM = typeService.DelGlobalType(ID);
        if (NUM>0)
        {
            return AjaxResult.success();
        }
        return  AjaxResult.error();

    }

    /**
     * 新增方法
     * @param eastVOS 新增实体类
     * @return 状态码
     */
    @ApiOperation(value = "新增方法",httpMethod = "POST")
    @RequestMapping(value = "/IntoGlobalType",method = {RequestMethod.POST})
    public AjaxResult IntoGlobalType(@RequestBody GlobalTypeVO eastVOS)
    {
        eastVOS.setCreateTime(LocalDateTime.now());
        int NUM =  typeService.IntoGlobalType(eastVOS);
        if (NUM>0)
        {
            return AjaxResult.success();
        }
        return  AjaxResult.error();
    }

}
